package com.mvc.demo.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mvc.demo.service.INamedService;
import com.mvc.demo.service.IService;
import com.mvc.framework.annotation.MyAutowired;
import com.mvc.framework.annotation.MyController;
import com.mvc.framework.annotation.MyRequestMapping;
import com.mvc.framework.annotation.MyRequestParam;
import com.mvc.framework.servlet.MyModelAndView;

@MyController
@MyRequestMapping("/web")
public class FirstAction {

	@MyAutowired
	private IService service;

	@MyAutowired("myName")
	private INamedService namedService;

	@MyRequestMapping("/add.json")
	public MyModelAndView add(HttpServletRequest request, HttpServletResponse response, @MyRequestParam(value = "name") String name, @MyRequestParam(value = "addr") String addr) {
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("name", name);
		model.put("addr", addr);
		return new MyModelAndView("first.pgml", model);
	}
}
